{include file="base/_meta" /}
</head>
<body>

<!-- 正文开始 -->
<div class="layui-fluid layui-form">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row">

                <input type="hidden" name="id" value="{$data.id|default=''}">

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">名称:</label>
                    <div class="layui-input-block">
                        <input name="name" class="layui-input" placeholder="输入分类名称" value="{$data.name}"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">排序:</label>
                    <div class="layui-input-block">
                        <input name="sort" class="layui-input" placeholder="输入分类排序" value="{$data.sort}"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">图片:</label>
                    <div class="layui-input-block">
                        <!--单文件上传-->
                        <div class="layui-upload-drag" id="img" onclick="upload_file('img',1)">
                            <div>
                                <img src="{$data.img|default='/static/images/default_img.png'}" alt="上传成功后渲染" style="max-width: 96px">
                                <input type="hidden" name="img" value="{$data.img}">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="show" value="10" title="显示" {neq name="$data.show" value="20"}checked{/neq}>
                        <input type="radio" name="show" value="20" title="隐藏" {eq name="$data.show" value="20"}checked{/eq}>
                    </div>
                </div>


                <div class="layui-form-item">
                    <button class="layui-btn" lay-filter="authoritiesEditSubmit" lay-submit>保存</button>
                </div>

            </div>
        </div>
    </div>
</div>

<!-- js部分 -->
{include file="base/_script" /}
<script>
    layui.use(['layer', 'form', 'admin','xmSelect'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;

        /* 监听表单提交 */
        form.on('submit(authoritiesEditSubmit)', function (data) {
            $.get("{:url('shop/cate_save')}", data.field, function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg, {icon: 1,time:1000},function () {
                        admin.closeThisTabs()
                    });
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }, 'json');
            return false;
        });
    });
</script>
</body>
</html>
